#include <bits/stdc++.h>
#define File(xxx) freopen(xxx".in","r",stdin),freopen(xxx".out","w",stdout)
using namespace std;
typedef long long LL;
const int N = 1e5+5;
int t, n, u, v, ds[N], siz[N], gs, ans;
LL mn[N], a[N];
vector <int> to[N];

template <typename T> inline void debug(T x) { cerr<<x; }
template <typename T, typename ...T_> inline void debug(T x, T_ ...p) { cerr<<x<<' ', debug(p...); }
template <typename T> void read(T& x) {
	x = 0; int f = 0; char c = getchar();
	while(c < '0' || c > '9') f |= (c == '-'), c=getchar();
	while(c >= '0' && c <= '9') x=(x<<1)+(x<<3)+(c^48), c=getchar();
	x=(f ? -x : x);
}
int lne; char put[105];
template <typename T> void write(T x, char ch) {
	lne = 0; if(x < 0) putchar('-'), x=-x;
	do { put[++lne]=x%10, x/=10; } while(x);
	while(lne) putchar(put[lne--]^48);
	putchar(ch);
}
void dfs(int x, int fa) {
	if(ds[x] == 1) {
		mn[x]=a[x];
		return ;
	}
	LL op = 0;
	for(int i = 0; i < to[x].size(); ++i)
		if(to[x][i] != fa) {
			dfs(to[x][i], x);
			op+=mn[to[x][i]];
		}
	if(op-a[x] < 0)
		ans=0;
	mn[x]=2LL*a[x]-op;
	if(mn[x] < 0)
		ans=0;
	if(op == 0 && a[x])
		ans=0;
}

signed main() {
	File("clean");
	read(t);
	while(t--) {
		read(n);
		gs=0;
		for(int i = 1; i <= n; ++i)
			to[i].clear(), mn[i]=0, ds[i]=0, read(a[i]);
		for(int i = 2; i <= n; ++i)
			read(u), read(v), ++ds[u], ++ds[v], to[u].push_back(v), to[v].push_back(u);
		if(n == 1) {
			if(a[1] == 0)
				puts("YES");
			else
				puts("NO");
			continue;
		}
		if(n == 2) {
			if(a[1] == a[2])
				puts("YES");
			else
				puts("NO");
			continue;
		}
		LL pp = 0;
		for(int i = 1; i <= n; ++i)
			gs+=(ds[i] == 1), pp+=(ds[i] == 1 ? a[i] : 0);
		if(pp%2 == 1) {
			puts("NO");
			continue;
		}
		int rt = 0;
		for(int i = 1; i <= n; ++i)
			if(ds[i] != 1)
				rt=i;
		ans=1;
		dfs(rt, 0);
		ans&=(mn[rt] == 0);
		if(ans)
			puts("YES");
		else
			puts("NO");
	}
	return 0;
}